@extends('Admin.Layout.main')
@section('privateheader')
<!-- DataTables -->
<link rel="stylesheet" href="{{__BASE__}}/admin/plugins/datatables/dataTables.bootstrap.css">
<style>
    .showmsg{
        min-width: 300px;
        border:1px solid #ccc;
        background:#fff;
        position: absolute;
        left:50%;
        top:200px;
        display: none;
    }
    .msgbody{
        clear: both;
        padding:10px;
        text-align: center;
    }
    .showmsg button{
        margin-top:10px;
        float:right;
        margin-right:10px;
    }
    .msgbody table{
        margin-left:25px;

    }
    .msgbody tr td{
        border: 1px solid #ccc;
    }
</style>
@endsection
@section('content')
        <!-- Main content -->
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <h3 class="box-title" style="float: left;"> 系统日志管理</h3>
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <table class="table table-bordered table-striped">
                        <thead>
                        <tr>
                            <th>日志ID</th>
                            <th>访问参数</th>
                            <th>城市</th>
                            <th>操作行为</th>
                            <th>操作时间</th>
                            <th>IP</th>
                        </tr>
                        </thead>
                        <tbody>
                        @if(!empty($data['list']))
                            @foreach($data['list'] as $k => $v)
                                <tr>
                                    <td>{{$v->id or ''}}</td>
                                    <td><button class="btn bg-orange getparam" param="{{$v->param or ''}}">点击查看</button></td>
                                    <td>{{$v->city or ''}}</td>
                                    <td>{!! $v->con or ''!!}</td>
                                    <td>{{date('Y-m-d H:i:s',$v->create_time)}}</td>
                                    <td>{{$v->ip or ''}}</td>
                                </tr>
                            @endforeach
                        @endif
                        </tbody>
                    </table>
                    @if(!empty($data['list']))
                        <?php
                            if(!empty($_GET['menu_id']))
                            {
                                $data['list'] = $data['list']->appends(['menu_id'=>$_GET['menu_id']]);
                            }
                            if(!empty($_GET['title']))
                            {
                                $data['list'] = $data['list']->appends(['title'=>$_GET['title']]);
                            }
                        ?>
                        {!! $data['list']->render() !!}
                    @endif
                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->
        </div>
        <!-- /.col -->
    </div>
    <!-- /.row -->
    <div class="showmsg">
        <button class="btn bg-red">关闭</button>
        <div class="msgbody"></div>
    </div>
</section>
@endsection
@section('privatefooter')
<!-- DataTables -->
<script src="{{__BASE__}}/admin/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="{{__BASE__}}/admin/plugins/datatables/dataTables.bootstrap.min.js"></script>
<script>
    $(function(){
        //点击查看弹框
        $(".getparam").on("click",function(){
            var param = $(this).attr("param");
            param = param != '' ? eval("("+param+")") : '';
            var str = '<table>';
            for(a in param)
            {
                if(typeof param[a] === "object")
                {
                    for(b in param[a])
                    {
                        str += '<tr>';
                        str += '<td>'+b+'</td>';
                        str += '<td>'+param[a][b]+'</td>';
                        str += '</tr>';
                    }
                }else{
                    str += '<tr>';
                    str += '<td>'+a+'</td>';
                    str += '<td>'+param[a]+'</td>';
                    str += '</tr>';
                }
            }
            str += '</table>';
            $(".msgbody").html(str);
            //设置弹框居中
            var showMsgw = (parseInt($(".showmsg").width())/2)*-1;
            $(".showmsg").css("marginLeft",showMsgw);
            $(".showmsg").show();
        });

        $(".showmsg button").on("click",function(){
            $(".showmsg").hide();
        });

    })
</script>
<!-- page script -->
@endsection